local tuanzhang = fk.CreateSkill {
  name = "cf_tuanzhang",
  tags = { Skill.Lord },
  attached_skill_name = "cf_tuanzhang_active&"
}

Fk:loadTranslationTable {
  ["cf_tuanzhang"] = "团长",
  [":cf_tuanzhang"] = "主公技，其他【蒙德】势力角色出牌阶段限一次，其可以交给你一张牌，然后你选择一项：1.令其从牌堆顶和牌堆底各摸一张牌。2.令其回复一点体力。3.令其下次造成伤害翻倍。",
  ["$cf_tuanzhang1"] = "希望大家都能获得宝藏。",
  ["$cf_tuanzhang2"] = "骑士团的大家，有没有认真工作呢。",
}

tuanzhang:addAcquireEffect(function(self, player, is_start)
  local room = player.room
  for _, p in ipairs(room:getOtherPlayers(player, false)) do
    if p.kingdom == "Mondstadt" then
      room:handleAddLoseSkills(p, tuanzhang.name .. "_active&", nil, false, true)
    else
      room:handleAddLoseSkills(p, "-" .. tuanzhang.name .. "_active&", nil, false, true)
    end
  end
end)

tuanzhang:addEffect(fk.AfterPropertyChange, {
  mute = true,
  can_refresh = function(self, event, target, player, data)
    return target == player
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if player.kingdom == "Mondstadt" and table.find(room.alive_players, function(p)
          return p ~= player and p:hasSkill(tuanzhang.name, true)
        end) then
      room:handleAddLoseSkills(player, tuanzhang.name .. "_active&", nil, false, true)
    else
      room:handleAddLoseSkills(player, "-" .. tuanzhang.name .. "_active&", nil, false, true)
    end
  end,
})

return tuanzhang
